package be.kuleuven.peno3.mobiletoledo.Data.Client;

import java.io.IOException;

import com.google.gson.Gson;
import com.google.gson.JsonParseException;

public abstract class CredentialsClient extends Client{
	
	public static String testCredentials(String userid, String password) {
		try {
			String url ="userid="+userid+"&password="+password;
			url=encode(url);
			url=host+"/CredentialsHandler/testCredentials?"+url;
			String json = stringOfUrl(url);
			
			String result=null;
			try {
				result = new Gson().fromJson(json.toString(), String.class);
			}
			catch (JsonParseException ex) {
				result = "failed";
			}
			return result;
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ArrayIndexOutOfBoundsException ex) {
			ex.printStackTrace();
		}
		return "failed";
	}
	
//	private static class Credential{String username, password, teacher;}
}
